package com.winning.sjzc.common.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
* @Author: nxs@winning.com.cn
*
* @Description:   常用方法公共类
*
* @Date: 2018-07-14 01:44:42
*
*
 **/
public class Common {



    /**
     * *********************
     *
     * @Description:  打印控制台日志
     */

    public static void printWorkLog(Object object, String mode) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        StringBuffer sb = new StringBuffer(50);
        sb.append("receiving on ").append(dateFormat.format(new Date()))
                .append(" at ").append(object.getClass().getName()).append("-")
                .append(mode);
    }


    /**
     * ************************
     *
     * @Description: 验证参数
     */
    public static boolean validateParams(Map<String, String> map,
                                         final String... params) {
        boolean validateFlag = true;
        for (String param : params) {
            String val = map.get(param);
            if (val == null || "".equals(val) || "undefined".equals(val)) {
                validateFlag = false;
                break;
            }
        }
        return validateFlag;
    }

    /**
     * **********************
     *
     * @param params
     * @return
     * @Description: 验证参数
     */
    public static boolean validateParams(final String... params) {
        boolean validateFlag = true;
        for (String param : params) {
            if (param == null || "".equals(param) || "undefined".equals(param)) {
                validateFlag = false;
                break;
            }
        }
        return validateFlag;
    }


   }
